# coding:utf-8

import os
import sys


def del_file(dirpath, postfix):
    """删除指定目录及其子目录下以postfix后缀名结尾的文件.
    """
    if os.path.isdir(dirpath):
        for fpath, dirname, fnames in os.walk(dirpath):
            for fname in fnames:
                childname = os.path.join(fpath, fname)
                if os.path.isdir(childname):
                    del_file(childname, postfix)
                else:
                    name = str(fname)
                    if name.endswith(postfix):
                        os.remove(childname)
                        print(str(childname))


if __name__ == "__main__":
    if len(sys.argv)<3:
        pass
    else:
        print(sys.argv[1], sys.argv[2])
        del_file(sys.argv[1], sys.argv[2])
